package tcln.gxtx.client.utils.store;

import com.extjs.gxt.ui.client.data.ModelData;

/**
 * Factory class for {@link RecordUpdater}s.
 * 
 * @author Truong Chau Lien Ngoc (lienngoc@gmail.com)
 */
public final class RecordUpdaterFactory {

    private RecordUpdaterFactory() {
        // to hide
    }

    /**
     * Returns the default implementation of a {@link RecordUpdater}.
     * 
     * @param <M>
     * @return A new instance of {@link DefaultRecordUpdater}.
     */
    public static <M extends ModelData> RecordUpdater<M> getDefault() {
        return new DefaultRecordUpdater<M>();
    }

    /**
     * Returns the 'optimizable' implementation of a {@link RecordUpdater}.
     * 
     * @param <M>
     * @param modelClass
     * @return A new instance of {@link OptimizableRecordUpdater}.
     */
    public static <M extends ModelData> RecordUpdater<M> getOptimizable(Class<M> modelClass) {
        return new OptimizableRecordUpdater<M>();
    }

    /**
     * Returns the implementation of a {@link RecordUpdater} which updates directly changes to model, not record.
     * 
     * @param <M>
     * @param modelClass
     * @return A new instance of {@link ModelTargetedRecordUpdater}.
     */
    public static <M extends ModelData> RecordUpdater<M> getModelTargeted(Class<M> modelClass) {
        return new ModelTargetedRecordUpdater<M>();
    }
}
